// 某个元素数组中是否有某个元素，如果有，就添加，如果没有就返回
function isExitInArray(element, array) {
  const { name } = element
  const find = array.find(t => t.name === name)
  if (find) return false
  else array.push(element)
}

// 支持的系统功能列表
const specialSysFunction = [
  {
    path: '/user/iot',
    name: '阿里Iot',
    id: 'iot',
    className: 'iconfont iconfont-iot'
  },
  {
    path: '/user/temperature',
    name: '温湿度',
    id: 'humitureState',
    className: 'fa-thermometer'
  },
  {
    path: '/user/video',
    name: '热成像监控',
    id: 'thermalImager',
    className: 'fa-video-camera'
  }
]

// 生成默认系统功能之外的其他功能
export const genSpecialFunction = params => {
  const keys = Object.keys(params)
  const trueKeys = keys.filter(t => params[t])
  const result = trueKeys.map(t => {
    return specialSysFunction.find(tt => tt.id === t)
  })
  // [...tabOfUser.slice(0)].concat({}) 插入元素在倒数第二个位置
  if (result.length === 0) {
    return [...tabOfUser]
  }
  const arr = [
    {
      path: result[0].path,
      name: '其他监控',
      className: 'fa-cubes',
      children: result
    }
  ]
  return [...tabOfUser].concat(arr)
}

export const tabOfAdmin = [
  {
    path: '/dashboard',
    name: '数据中心',
    className: 'fa-dashboard'
  },
  {
    name: '企业管理',
    path: '/company',
    className: 'fa-cubes'
  },

  {
    name: '智慧用电',
    path: '/alarm',
    className: 'fa-exclamation-triangle',
    children: [
      {
        name: '设备管理',
        path: '/device',
        className: 'fa-window-restore'
      },
      {
        name: '报警事件',
        path: '/alarm',
        className: 'fa-bell-slash'
      },
      {
        path: '/history',
        name: '历史数据',
        className: 'fa-list-alt'
      },
      {
        path: '/offline',
        name: '离线统计',
        className: 'fa-database'
      }
    ]
  },

  {
    path: '/video',
    name: '热成像监控',
    className: 'fa-video-camera'
  },
  {
    path: '/temperature',
    name: '温湿度',
    className: 'fa-thermometer'
  },
  {
    path: '/iot',
    name: '阿里Iot',
    className: 'iconfont iconfont-iot'
  },
  {
    path: '/setting',
    name: ' 系统管理 ',
    className: 'fa-cog'
  }
]

export const tabOfUser = [
  {
    path: '/user/main',
    name: '首页',
    className: 'fa-home'
  },
  {
    path: '/user/device',
    name: '智慧用电',
    className: 'fa-exclamation-triangle',
    children: [
      {
        path: '/user/device',
        name: '设备管理',
        className: 'fa-window-restore'
      },
      {
        path: '/user/errorthing',
        name: '报警事件',
        className: 'fa-bell-slash'
      },
      {
        path: '/user/history',
        name: '历史数据',
        className: 'fa-list-alt'
      },
      {
        path: '/user/report',
        name: '诊断报告',
        className: 'fa-pie-chart'
      },
      {
        path: '/analysis',
        name: '能效分析',
        className: 'fa-cogs'
      }
    ]
  }
]

export const nameUserNav = [
  '/guide',
  'userMain',
  'userDevice',
  'userErrorthing',
  'userHistory',
  'userReport',
  // '/report/detail',
  'userVideo',
  'userVideoDetail',
  'userVideoDistribute',
  'userVideoPlayer',
  'userTemperature',
  'userTemperatureDetail',
  'EnergyEfficiencyAnalysis',
  'AnalyisisReport',
  'AnalyisisLoad',
  'AnalyisisBattery',
  'AnalyisisVoltage',
  'AnalyisisCurrent',
  'AnalyisisPowerFactor'
]

export const nameAdminNav = [
  'admin-company',
  'admin-company-info',
  'admin-device',
  'admin-device-info',
  'admin-alarm',
  'admin-history',
  'admin-offline',
  'admin-settingcity',
  'admin-settingarticle',
  'admin-settinguser',
  'admin-settingoffline',
  'admin-settingRegion',
  'admin-setting-type',
  'admin-setting-trade',
  'admin-setting-gateway-type',
  'admin-setting-gateway-list',
  'admin-setting-build-report',
  'admin-videoDevice',
  'admin-videoAlarm',
  'admin-videoParams',
  'admin-videoDeviceInfo',
  'admin-videoDistribute',
  'admin-videoPlayer',
  'admin-temperatureDevice',
  'admin-temperatureAlarm',
  'admin-temperatureParams',
  'admin-temperatureDevice-detail',
  'admin-setting-company-channel',

  /**
   * iot 部分
   */
  'admin-iot-device',
  'admin-iot',
  'admin-iot-alert',
  'admin-iot-history',
  'admin-iot-device-detail'
]
